package com.qike.duola.utils;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;
import org.springframework.stereotype.Component;

@Component
public final class StringUtil {


    /**
     * 拼接string
     * @return
     */
    public static String contractString(Double percent,Integer days) {
        if (percent==null){
            percent = new Double(80);
        }
        if (days==null){
            days = 70;
        }
        String message = String.format("每月支付%s 剩余砼款待该工程主体封顶后%d天内全部付清。", percent, days);
        return message;
    }

    public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){

        //创建GeodeticCalculator，调用计算方法，传入坐标系、经纬度用于计算距离
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo);

        return geoCurve.getEllipsoidalDistance();
    }

    public static void main(String[] args) {
        Double percent = new Double(80);
        Integer days = 90;
        String message = String.format("每月支付%s 剩余砼款待该工程主体封顶后%d天内全部付清。", percent, days);
        System.out.println(message);
    }
}
